<template>
  <div style="display:inline-block;">
    <a-button style="margin-left: 10px;" type="primary" @click="() => { showSpecial = true; specialFlag='1' }">
      特殊单据(增单)
      <span class="tsdj_tip" v-show="selectRowsData.length > 0">{{ selectRowsData.length }}</span>
    </a-button>
    <a-button style="margin-left: 10px;" type="primary" @click="() => { showSpecial = true; specialFlag='2' }">
      特殊单据(减单)
      <span class="tsdj_tip" v-show="selectRowsData2.length > 0">{{ selectRowsData2.length }}</span>
    </a-button>
    <a-modal
      :visible="showSpecial"
      width="80%"
      :bodyStyle="{
        paddingBottom: 0,
      }"
      @cancel="() => { showSpecial = false }"
      @ok="selectSpecial">
      <Special ref="special"></Special>
    </a-modal>
  </div>
</template>
<script>
import Special from './special.vue'

export default {
  components: { Special },
  data () {
    return {
      data: [],
      loading: false,
      addModal: false,
      calc6Total: '',
      calc6Num: '',
      calc6_1Total: '',
      calc6_1Num: '',
      calc4Total: '',
      calc4Num: '',
      pagination: {
        current: 1,
        pageSize: 25,
        showTotal: (total, range) => `总数:${total} 当前:${range[0]}-${range[1]}`,
        pageSizeOptions: ['25', '50', '100'], // 设置pageSize的可选值，页面可以通过下拉框进行选择
        showSizeChanger: true
      },
      calcModal: false,
      calcResult: false,
      calcMsg: '',
      selectRowsData: [],
      selectRowsData2: [],
      showSpecial: false,
      progressValue: 0,
      specialFlag: '1' // 1 增单 2 减单
    }
  },
  watch: {
    showSpecial (val) {
      if (val) {
        let rowIds = []
        if (this.specialFlag == '1') {
          rowIds = this.selectRowsData
        }
        if (this.specialFlag == '2') {
          rowIds = this.selectRowsData2
        }
        this.$refs.special.openForm(rowIds || [])
      }
    }
  },
  methods: {
    selectSpecial () {
      if (this.specialFlag == '1') {
        this.selectRowsData = this.$refs.special.selectRows
      }
      if (this.specialFlag == '2') {
        this.selectRowsData2 = this.$refs.special.selectRows
      }
      this.showSpecial = false
      this.$emit('selectfun', {
        ids: this.selectRowsData,
        ids1: this.selectRowsData2
      })
    }
  }
}
</script>
<style lang="less" scoped>
	.tsdj_tip{
		padding:0 5px;
		background: red;
		margin-left: 3px;
		font-size: 10px;
		border-radius: 20px;
	}
</style>
